<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>Title</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0,maximum-scale=1.0, user-scalable=no"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
    <meta name="renderer" content="webkit">
    <link rel="stylesheet" href="/mdui/css/mdui.min.css">
    <script defer src="/mdui/js/mdui.min.js"></script>
    <script src="/js/axios.min.js"></script>
    <script src="/js/qs.min.js"></script>
    <script src="/js/common.js"></script>
    <script src="/js/vue.js"></script>
    <style>
        .mdui-table-fluid {
            width: 1200px;
        }

        .mdui-table {
            border: 1px solid #d6d6d6;
        }

        .mdui-btn {
            margin-right: 100px;
        }

        a {
            text-decoration: none;
        }

        .mdui-table-fluid {
            width: 800px;
        }

        .mdui-table td img {
            height: 100px;
            width: 140px;
        }

    </style>

</head>

<body class="mdui-theme-primary-indigo mdui-theme-accent-pink">
<div class="mdui-container-fluid" id="app">
    <h3>报修单编号{{repair.id}}</h3>
    <button class="mdui-btn mdui-color-green-800 mdui-ripple"><a href="list.html"
                                                                 class=" mdui-color-green-800">返回上一级</a>
    </button>
    <!--    <button v-if="flag" class="mdui-btn mdui-color-green-800 mdui-ripple arrangment "><a-->
    <!--            :href="'arrangment.html?id=' +repair.id"-->
    <!--            class=" mdui-color-green-800">安排维修</a>-->
    <!--    </button>-->
    <!--    </button>-->
    <!--    <button v-if="flag1" class="mdui-btn mdui-color-green-800 mdui-ripple cancel" @click="cancelRepair">取消改报修单-->
    <!--    </button>-->
    <!--    <button v-if="flag2" class="mdui-btn mdui-color-green-800 mdui-ripple sure" @click="sureRepair">确认检修</button>-->
    <div class="mdui-table-fluid">
        <table class="mdui-table">
            <thead>
            <tr>
                <th>特征</th>
                <th>描述</th>
            </tr>
            </thead>
            <tbody>
            <tr>
                <td>地点</td>
                <td>{{repair.place}}</td>
            </tr>
            <tr>
                <td>时间</td>
                <td>{{repair.submitTime}}</td>
            </tr>
            <tr>
                <td>状态</td>
                <td>{{repair.status |fmtGenter}}</td>
            </tr>
            <tr>
                <td>详情</td>
                <td>{{repair.detail}}</td>
            </tr>
            <tr>
                <td>图片</td>
                <td class="img-hight"><img :src="'/repair/downlode/' + repair.id">
                </td>
            </tr>
            </tbody>
        </table>
    </div>
</div>
</body>
<script>
    let params = new URLSearchParams(location.search);//location.searc url中参数的部分包括问号
    let repairid = params.get("id")
    new Vue({
        el: '#app',
        data: {
            repair: {
                id: '',
                status: "",
                detail: "",
                place: "",
                picMD5: "",
                submitTime: ""
            },
            flag: true,
            flag1: true,
            flag2: true
        },
        created() {
            let _this = this
            axios.get("/repair/findById?id=" + repairid)
                .then(function (res) {
                    _this.repair = res.data;
                    if (res.data.status == 3 || res.data.status == 5) {
                        _this.flag = false;
                        _this.flag1 = false;
                        _this.flag2 = false;
                    } else if (res.data.status == 2) {
                        _this.flag1 = false;
                    }
                })
        },
        filters: {
            fmtGenter(val) {
                if (val == 1) {
                    return "未安排维修维修"
                } else if (val == 2) {
                    return "已安排检修"
                } else if (val == 3) {
                    return "待同意取消"
                } else if (val == 4) {
                    return "已同意取消"
                } else if (val == 5) {
                    return "待验收"
                } else if (val == 5) {
                    return "已验收"
                }
            }
        },
        methods: {
            sureRepair() {
                console.log(this.name)
                let _this = this
                axios.get("/maintenance/sure", {
                    params: {
                        id: repairid
                    }
                })
                    .then(function (res) {
                        if (res.data) {
                            mdui.alert("已确认验收")
                            window.location.href = 'list.html'
                        }
                    })
            },
            cancelRepair() {
                console.log(this.name)
                let _this = this
                axios.get("/maintenance/cancel", {
                    params: {
                        id: repairid
                    }
                })
                    .then(function (res) {
                        if (res.data) {
                            mdui.alert("取消成功")
                            window.location.href = 'list.html'
                        }
                    })
            },
        }
    })
</script>
</body>
</html>